package nus.mtech;

import java.util.ArrayList;
import java.util.Date;

import nus.mtech.bill.BillManager;
import nus.mtech.customer.Complaint;
import nus.mtech.customer.ComplaintManager;
import nus.mtech.customer.Customer;
import nus.mtech.customer.CustomerManager;
import nus.mtech.subscription.CableTV;
import nus.mtech.subscription.ExtraFeature;
import nus.mtech.subscription.Subscription;
import nus.mtech.subscription.SubscriptionManager;
import nus.mtech.subscription.ExtraFeature.ExtraFeatureType;
import nus.mtech.user.AuthenticationManager;
import nus.mtech.user.User;

public class ApplicationFacade {
	private static ApplicationFacade applicationFacade;
	private ComplaintManager complaintManager;
	private CustomerManager customerManager;
	private SubscriptionManager subscriptionManager;
	private AuthenticationManager authenticatinManager;
	private BillManager billManager;
	private ApplicationFacade(){
		complaintManager = ComplaintManager.getComplaintManagerInstance();
		customerManager = CustomerManager.getCustomerManagerInstance();
		subscriptionManager = SubscriptionManager.getSubscriptionManagerInstance();
		authenticatinManager = AuthenticationManager.getInstance();
		billManager = BillManager.getBillManagerInstance();
	}
	public static ApplicationFacade getInstance(){
		if(applicationFacade == null)
			applicationFacade = new ApplicationFacade();
		return applicationFacade;
	}
	
	public int getComplaintId(){
		return complaintManager.getComplaintId();
	}
	public int updateComplaint(String accountNo, int complaintID, String compFinding, Boolean status) {
		return complaintManager.updateComplaint(accountNo, complaintID, compFinding, status);
	}
	public Complaint getComplaintByComplaintID(String accountNo, int complaintID) {
		return complaintManager.getComplaintByComplaintID(accountNo, complaintID);
	}
	
	public void addNewComplaint(String accountNo, Complaint complaint) {
		// TODO Auto-generated method stub
		complaintManager.addNewComplaint(accountNo, complaint);
	}
	public void setComplaintId(int complaintId) {
		// TODO Auto-generated method stub
		complaintManager.setComplaintId(complaintId);
	}
	public ArrayList<Complaint> getComplaintByAccountNo(String accountNo) {
		// TODO Auto-generated method stub
		return complaintManager.getComplaintByAccountNo(accountNo);
	}
	public Customer getCustomerByNRIC(String custNRIC) {
		// TODO Auto-generated method stub
		return customerManager.getCustomerByNRIC(custNRIC);
	}
	public void updateCustomerDetails(Customer cust) {
		// TODO Auto-generated method stub
		customerManager.updateCustomerDetails(cust);
	}
	public void addNewCustomer(Customer customer) {
		// TODO Auto-generated method stub
		customerManager.addNewCustomer(customer);
	}
	public Customer getCustomerByAccountNo(String custAccountNo) {
		// TODO Auto-generated method stub
		return customerManager.getCustomerByAccountNo(custAccountNo);
	}
	public ArrayList<Subscription> getSubscription(String accountNo) {
		// TODO Auto-generated method stub
		return subscriptionManager.getSubscription(accountNo);
	}
	public User login(String userName, String password) {
		// TODO Auto-generated method stub
		return authenticatinManager.login(userName, password);
	}

	public boolean generateMonthlyBill(Date date) {
		// TODO Auto-generated method stub
		return billManager.generateMonthlyBill(date);
	}
	
	public void addSubscription(String accountNo, Subscription newSubscriptionObject){
		subscriptionManager.addSubscription(accountNo, newSubscriptionObject);
	}
	public void addExtraCableTVChannels(String lCableTVName, Date startDate, Date endDate, CableTV cableTVObj){
		subscriptionManager.addExtraCableTVChannels(lCableTVName, startDate, endDate, cableTVObj);
	}
	public String getBillStatement(String accountNo, Date date) {
		return billManager.getBillStatement(accountNo, date);
	}
	public ExtraFeature getExtraFeaturesFromSubscription(ExtraFeatureType type, Subscription subObj){
		return subscriptionManager.getExtraFeaturesFromSubscription(type, subObj);
	}
	public void addExtraFeature(ExtraFeatureType type, Date startDate, Date endDate, boolean activeStatus, Subscription lSubObject){
		subscriptionManager.addExtraFeature(type, startDate, endDate, activeStatus, lSubObject);
	}
}